package com.artwork.service.impl;

import com.artwork.mapper.SignMapper;
import com.artwork.model.Sign;
import com.artwork.service.SignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author JoJo
 * @Data 2021/9/9$ 9:37$
 * @Description
 * @Param $
 * @Return $
 */
@Service
public class SignServiceImpl implements SignService {
    @Autowired
    SignMapper signMapper;

    @Override
    public int addSign(int userId) {
        Sign sign = new Sign();
        sign.setDays(1);
        sign.setCreateTime(System.currentTimeMillis());
        sign.setUpdateTime(System.currentTimeMillis());
        sign.setUserId(userId);
        return signMapper.insertSelective(sign);
    }

    @Override
    public Sign getUserSign(int userId) {
        return signMapper.selectByUserId(userId);
    }

    @Override
    public int updateSign(Sign sign) {
        return signMapper.updateByPrimaryKeySelective(sign);
    }
}
